; ModuleID = 'count.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"

%struct.ompi_communicator_t = type opaque
%struct.ompi_datatype_t = type opaque
%struct.ompi_predefined_communicator_t = type opaque
%struct.ompi_predefined_datatype_t = type opaque
%struct.ompi_status_public_t = type { i32, i32, i32, i32, i32 }

@ompi_mpi_comm_world = external global %struct.ompi_predefined_communicator_t
@ompi_mpi_float = external global %struct.ompi_predefined_datatype_t
@.str = private constant [7 x i8] c"%3.1f \00"
@.str1 = private constant [2 x i8] c"\0A\00"

define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
  %retval = alloca i32, align 4
  %argc.addr = alloca i32, align 4
  %argv.addr = alloca i8**, align 4
  %vector = alloca [100 x float], align 4
  %status = alloca %struct.ompi_status_public_t, align 4
  %p = alloca i32, align 4
  %my_rank = alloca i32, align 4
  %i = alloca i32, align 4
  store i32 0, i32* %retval
  store i32 %argc, i32* %argc.addr, align 4
  store i8** %argv, i8*** %argv.addr, align 4
  %call = call i32 @MPI_Init(i32* %argc.addr, i8*** %argv.addr)
  %call1 = call i32 @MPI_Comm_size(%struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), i32* %p)
  %call2 = call i32 @MPI_Comm_rank(%struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), i32* %my_rank)
  %tmp = load i32* %my_rank, align 4
  %cmp = icmp eq i32 %tmp, 0
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  store i32 0, i32* %i, align 4
  br label %for.cond

for.cond:                                         ; preds = %for.inc, %if.then
  %tmp3 = load i32* %i, align 4
  %cmp4 = icmp slt i32 %tmp3, 50
  br i1 %cmp4, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  %tmp5 = load i32* %i, align 4
  %arrayidx = getelementptr inbounds [100 x float]* %vector, i32 0, i32 %tmp5
  store float 0.000000e+00, float* %arrayidx
  br label %for.inc

for.inc:                                          ; preds = %for.body
  %tmp6 = load i32* %i, align 4
  %inc = add nsw i32 %tmp6, 1
  store i32 %inc, i32* %i, align 4
  br label %for.cond

for.end:                                          ; preds = %for.cond
  store i32 50, i32* %i, align 4
  br label %for.cond7

for.cond7:                                        ; preds = %for.inc13, %for.end
  %tmp8 = load i32* %i, align 4
  %cmp9 = icmp slt i32 %tmp8, 100
  br i1 %cmp9, label %for.body10, label %for.end16

for.body10:                                       ; preds = %for.cond7
  %tmp11 = load i32* %i, align 4
  %arrayidx12 = getelementptr inbounds [100 x float]* %vector, i32 0, i32 %tmp11
  store float 1.000000e+00, float* %arrayidx12
  br label %for.inc13

for.inc13:                                        ; preds = %for.body10
  %tmp14 = load i32* %i, align 4
  %inc15 = add nsw i32 %tmp14, 1
  store i32 %inc15, i32* %i, align 4
  br label %for.cond7

for.end16:                                        ; preds = %for.cond7
  %arraydecay = getelementptr inbounds [100 x float]* %vector, i32 0, i32 0
  %add.ptr = getelementptr inbounds float* %arraydecay, i32 50
  %conv = bitcast float* %add.ptr to i8*
  %call17 = call i32 @MPI_Send(i8* %conv, i32 50, %struct.ompi_datatype_t* bitcast (%struct.ompi_predefined_datatype_t* @ompi_mpi_float to %struct.ompi_datatype_t*), i32 1, i32 0, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*))
  br label %if.end

if.else:                                          ; preds = %entry
  %arraydecay18 = getelementptr inbounds [100 x float]* %vector, i32 0, i32 0
  %add.ptr19 = getelementptr inbounds float* %arraydecay18, i32 50
  %conv20 = bitcast float* %add.ptr19 to i8*
  %call21 = call i32 @MPI_Recv(i8* %conv20, i32 50, %struct.ompi_datatype_t* bitcast (%struct.ompi_predefined_datatype_t* @ompi_mpi_float to %struct.ompi_datatype_t*), i32 0, i32 0, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), %struct.ompi_status_public_t* %status)
  store i32 50, i32* %i, align 4
  br label %for.cond22

for.cond22:                                       ; preds = %for.inc32, %if.else
  %tmp23 = load i32* %i, align 4
  %cmp24 = icmp slt i32 %tmp23, 100
  br i1 %cmp24, label %for.body26, label %for.end35

for.body26:                                       ; preds = %for.cond22
  %tmp27 = load i32* %i, align 4
  %arrayidx28 = getelementptr inbounds [100 x float]* %vector, i32 0, i32 %tmp27
  %tmp29 = load float* %arrayidx28
  %conv30 = fpext float %tmp29 to double
  %call31 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), double %conv30)
  br label %for.inc32

for.inc32:                                        ; preds = %for.body26
  %tmp33 = load i32* %i, align 4
  %inc34 = add nsw i32 %tmp33, 1
  store i32 %inc34, i32* %i, align 4
  br label %for.cond22

for.end35:                                        ; preds = %for.cond22
  %call36 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([2 x i8]* @.str1, i32 0, i32 0))
  br label %if.end

if.end:                                           ; preds = %for.end35, %for.end16
  %call37 = call i32 @MPI_Finalize()
  %0 = load i32* %retval
  ret i32 %0
}

declare i32 @MPI_Init(i32*, i8***)

declare i32 @MPI_Comm_size(%struct.ompi_communicator_t*, i32*)

declare i32 @MPI_Comm_rank(%struct.ompi_communicator_t*, i32*)

declare i32 @MPI_Send(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*)

declare i32 @MPI_Recv(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*, %struct.ompi_status_public_t*)

declare i32 @printf(i8*, ...)

declare i32 @MPI_Finalize()
